<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>伪类 - 表格</title>
</head>

<body>


    <form>
        <label for="url_input">输入链接:</label>
        <input type="url" id="url_input" />
        <br />
        <br />
        <label for="email_input">输入邮箱:</label>
        <input type="email" id="email_input" required />
    </form>

    :required 选择器在表单元素是必填项时设置指定样式。
    <hr />
    :valid 选择器在表单元素的值需要根据指定条件验证时设置指定样式。
    <hr />
    :invalid 选择器用于在表单元素中的值是非法时设置指定样式。
    <style>
        input:invalid {
            background-color: #ffdddd;
        }

        form:invalid {
            border: 5px solid #ffdddd;
        }

        input:valid {
            background-color: #ddffdd;
        }

        form:valid {
            border: 5px solid #ddffdd;
        }

        input:required {

            border-width: 3px;
        }

        input:required:invalid {
            border-color: #C00000;
        }
    </style>

</body>

</html>